// 角色管理模块-接口
import request from '@/util/request';

/**
 * 角色分页列表
 * @param {*} param 
 * @param {*} pageParam 
 * @returns 
 */
export function pages(param,pageParam){

    const data = {
        ...param,
        page:pageParam.page,
        size:pageParam.limit
    }
    return request({
        url:"/sys/role/pages",
        method:"GET",
        params: data
    });

}

/**
 * 授权用户列表
 * @param {*} param 
 * @param {*} pageParam 
 * @returns 
 */
export function roleUserpages(param,pageParam,roleID){

    const data = {
        ...param,
        page:pageParam.page,
        size:pageParam.limit,
        roleID:roleID
    }
    return request({
        url:"/sys/roleUser/pages",
        method:"GET",
        params: data
    });

}

/**
 * 获取角色授权菜单信息列表
 * @param {*} roleID 
 * @returns 
 */
export function getRoleMenuListByRoleID(roleID){

    const data = {
        roleID:roleID
    }
    return request({
        url:"/sys/role/getRoleMenuListByRoleID",
        method:"GET",
        params: data
    });

}

/**
 * 添加角色
 * @param {*} param 
 * @returns 
 */
export function addRole(param){

    const data = {
        ...param
    }
    return request({
        url:"/sys/role/add",
        method:"POST",
        data: data
    });

}

/**
 * 添加授权用户
 * @param {*} param 
 * @returns 
 */
export function addRoleUser(param){

    const data = {
        ...param
    }
    return request({
        url:"/sys/roleUser/add",
        method:"POST",
        data: data
    });

}

/**
 * 修改角色
 * @param {*} param 
 * @returns 
 */
export function updateRole(param){

    const data = {
        ...param
    }
    return request({
        url:"/sys/role/update",
        method:"PUT",
        data: data
    });

}

/**
 * 删除角色
 * @param {*} param 
 * @returns 
 */
export function deletesRole(param){

    const data = {
        ids:param
    }
    return request({
        url:"/sys/role/deletes",
        method:"DELETE",
        params: data
    });

}

/**
 * 移除授权用户信息
 * @param {*} param 
 * @returns 
 */
export function deletesRoleUsers(param){

    const data = {
        ids:param
    }
    return request({
        url:"/sys/roleUser/deletes",
        method:"DELETE",
        params: data
    });

}

/**
 * 修改授权菜单信息
 * @param {*} param 
 * @returns 
 */
export function updateMenuRoles(param){

    const data = {
        ...param
    }
    return request({
        url:"/sys/role/updateMenuRoles",
        method:"POST",
        data: data
    });

}


